Skip to content

Fix Android battery optimization not invoking callback#98

Merged
JulianAssmann merged 4 commits intoJulianAssmann:masterfrom
ahmetakil:android_battery_optimization_callback_fix
Mar 9, 2026
Merged

Fix Android battery optimization not invoking callback#98
JulianAssmann merged 4 commits intoJulianAssmann:masterfrom
ahmetakil:android_battery_optimization_callback_fix

Conversation

@ahmetakil
Copy link
Contributor

Fixes issues:

#76
#56

From my testing what I noticed is (Device: Samsung S23+) initially when the app requests the battery optimization, when user accepts PermissionActivityResultListener.onActivityResult is never called and initialize never returns to Flutter

My changes uses the lifecycle hooks onActivityPaused and onActivityResumed to actually respond when user taps the battery optimization dialog

With my changes:

  • Flutter calls FlutterBackground.initialize
  • User sees the battery optimization prompts and when accepts
  • The handleBatteryOptimizationReturn is invoked
  • Responds to flutter with the result

@ahmetakil ahmetakil changed the title Fix battery optimization not invoking callback Fix Android battery optimization not invoking callback Aug 21, 2025
@bardram
Copy link

bardram commented Mar 4, 2026

Hi @JulianAssmann - could we get this merged and released? We're all facing the issues described in #76 and #56...

Thx.

The PermissionHandler constructor was changed to only accept context,
but FlutterBackgroundPlugin was still passing 3 arguments. This fixes
the compilation error.
@JulianAssmann JulianAssmann merged commit bf52c18 into JulianAssmann:master Mar 9, 2026
JulianAssmann added a commit to emersion/flutter_background that referenced this pull request Mar 9, 2026
)

* Fix battery optimization not invoking callback

* Match PermissionHandler constructor in FlutterBackgroundPlugin

The PermissionHandler constructor was changed to only accept context,
but FlutterBackgroundPlugin was still passing 3 arguments. This fixes
the compilation error.

* Prepare release 1.3.1

* Bump version to 1.3.1 and fix analyzer warning

---------

Co-authored-by: Ahmet Akil <ahmetakil@cloud.upwork.com>
Co-authored-by: Julian Aßmann <kontakt@julianassmann.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants